home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2004 April / Gamestar_61_2004-04_dvdb.iso / DVDStar / Editace / hltp.exe / {app} / Source Code / Zoners Half-Life Tools / hlrad / vismatrixutil.cpp < prev   
C/C++ Source or Header  |  2002-12-09  |  22KB  |  713 lines

  1. #include "qrad.h"
  2.  
  3. funcCheckVisBit g_CheckVisBit = NULL;
  4.  
  5. unsigned        g_total_transfer = 0;
  6. unsigned        g_transfer_index_bytes = 0;
  7. unsigned        g_transfer_data_bytes = 0;
  8.  
  9. #define COMPRESSED_TRANSFERS
  10. //#undef  COMPRESSED_TRANSFERS
  11.  
  12. int             FindTransferOffsetPatchnum(transfer_index_t* tIndex, const patch_t* const patch, const unsigned patchnum)
  13. {
  14.     //
  15.     // binary search for match
  16.     //
  17.     int             low = 0;
  18.     int             high = patch->iIndex - 1;
  19.     int             offset;
  20.  
  21.     while (1)
  22.     {
  23.         offset = (low + high) / 2;
  24.  
  25.         if ((tIndex[offset].index + tIndex[offset].size) < patchnum)
  26.         {
  27.             low = offset + 1;
  28.         }
  29.         else if (tIndex[offset].index > patchnum)
  30.         {
  31.             high = offset - 1;
  32.         }
  33.         else
  34.         {
  35.             unsigned        x;
  36.             unsigned int    rval = 0;
  37.             transfer_index_t* pIndex = tIndex;
  38.  
  39.             for (x = 0; x < offset; x++, pIndex++)
  40.             {
  41.                 rval += pIndex->size + 1;
  42.             }
  43.             rval += patchnum - tIndex[offset].index;
  44.             return rval;
  45.         }
  46.         if (low > high)
  47.         {
  48.             return -1;
  49.         }
  50.     }
  51. }
  52.  
  53. #ifdef COMPRESSED_TRANSFERS
  54.  
  55. static unsigned GetLengthOfRun(const transfer_raw_index_t* raw, const transfer_raw_index_t* const end)
  56. {
  57.     unsigned        run_size = 0;
  58.  
  59.     while (raw < end)
  60.     {
  61.         if (((*raw) + 1) == (*(raw + 1)))
  62.         {
  63.             raw++;
  64.             run_size++;
  65.  
  66.             if (run_size >= MAX_COMPRESSED_TRANSFER_INDEX_SIZE)
  67.             {
  68.                 return run_size;
  69.             }
  70.         }
  71.         else
  72.         {
  73.             return run_size;
  74.         }
  75.     }
  76.     return run_size;
  77. }
  78.  
  79. static transfer_index_t* CompressTransferIndicies(transfer_raw_index_t* tRaw, const unsigned rawSize, unsigned* iSize)
  80. {
  81.     unsigned        x;
  82.     unsigned        size = rawSize;
  83.     unsigned        compressed_count = 0;
  84.  
  85.     transfer_raw_index_t* raw = tRaw;
  86.     transfer_raw_index_t* end = tRaw + rawSize - 1;        // -1 since we are comparing current with next and get errors when bumping into the 'end'
  87.  
  88.     transfer_index_t CompressedArray[MAX_PATCHES];         // somewhat big stack object (1 Mb with 256k patches)
  89.     transfer_index_t* compressed = CompressedArray;
  90.  
  91.     for (x = 0; x < size; x++, raw++, compressed++)
  92.     {
  93.         compressed->index = (*raw);
  94.         compressed->size = GetLengthOfRun(raw, end);       // Zero based (count 0 still implies 1 item in the list, so 256 max entries result)
  95.         raw += compressed->size;
  96.         x += compressed->size;
  97.         compressed_count++;                                // number of entries in compressed table
  98.     }
  99.  
  100.     *iSize = compressed_count;
  101.  
  102.     if (compressed_count)
  103.     {
  104.         unsigned        compressed_array_size = sizeof(transfer_index_t) * compressed_count;
  105.         transfer_index_t* rval = (transfer_index_t*)AllocBlock(compressed_array_size);
  106.  
  107.         ThreadLock();
  108.         g_transfer_index_bytes += compressed_array_size;
  109.         ThreadUnlock();
  110.  
  111.         memcpy(rval, CompressedArray, compressed_array_size);
  112.         return rval;
  113.     }
  114.     else
  115.     {
  116.         return NULL;
  117.     }
  118. }
  119.  
  120. #else
  121.  
  122. static transfer_index_t* CompressTransferIndicies(const transfer_raw_index_t* tRaw, const unsigned rawSize, unsigned* iSize)
  123. {
  124.     unsigned        x;
  125.     unsigned        size = rawSize;
  126.     unsigned        compressed_count = 0;
  127.  
  128.     transfer_raw_index_t* raw = tRaw;
  129.     transfer_raw_index_t* end = tRaw + rawSize;
  130.  
  131.     transfer_index_t CompressedArray[MAX_PATCHES];         // somewhat big stack object (1 Mb with 256k patches)
  132.     transfer_index_t* compressed = CompressedArray;
  133.  
  134.     for (x = 0; x < size; x++, raw++, compressed++)
  135.     {
  136.         compressed->index = (*raw);
  137.         compressed->size = 0;
  138.         compressed_count++;                                // number of entries in compressed table
  139.     }
  140.  
  141.     *iSize = compressed_count;
  142.  
  143.     if (compressed_count)
  144.     {
  145.         unsigned        compressed_array_size = sizeof(transfer_index_t) * compressed_count;
  146.         transfer_index_t* rval = AllocBlock(compressed_array_size);
  147.  
  148.         ThreadLock();
  149.         g_transfer_index_bytes += compressed_array_size;
  150.         ThreadUnlock();
  151.  
  152.         memcpy(rval, CompressedArray, compressed_array_size);
  153.         return rval;
  154.     }
  155.     else
  156.     {
  157.         return NULL;
  158.     }
  159. }
  160. #endif
  161.  
  162. /*
  163.  * =============
  164.  * MakeScales
  165.  * 
  166.  * This is the primary time sink.
  167.  * It can be run multi threaded.
  168.  * =============
  169.  */
  170. #ifdef SYSTEM_WIN32
  171. #pragma warning(push)
  172. #pragma warning(disable: 4100)                             // unreferenced formal parameter
  173. #endif
  174. void            MakeScales(const int threadnum)
  175. {
  176.     int             i;
  177.     unsigned        j;
  178.     vec3_t          delta;
  179.     vec_t           dist;
  180.     int             count;
  181.     float           trans;
  182.     patch_t*        patch;
  183.     patch_t*        patch2;
  184.     float           send;
  185.     vec3_t          origin;
  186.     vec_t           area;
  187.     const vec_t*    normal1;
  188.     const vec_t*    normal2;
  189.  
  190.     vec_t           total;
  191.  
  192.     transfer_raw_index_t* tIndex;
  193.     transfer_data_t* tData;
  194.  
  195.     transfer_raw_index_t* tIndex_All = (transfer_raw_index_t*)AllocBlock(sizeof(transfer_index_t) * MAX_PATCHES);
  196.     transfer_data_t* tData_All = (transfer_data_t*)AllocBlock(sizeof(transfer_data_t) * MAX_PATCHES);
  197.  
  198.     count = 0;
  199.  
  200.     while (1)
  201.     {
  202.         i = GetThreadWork();
  203.         if (i == -1)
  204.             break;
  205.  
  206.         patch = g_patches + i;
  207.         patch->iIndex = 0;
  208.         patch->iData = 0;
  209.  
  210.         total = 0.0;
  211.  
  212.         tIndex = tIndex_All;
  213.         tData = tData_All;
  214.  
  215.         VectorCopy(patch->origin, origin);
  216.         normal1 = getPlaneFromFaceNumber(patch->faceNumber)->normal;
  217.  
  218.         area = patch->area;
  219.  
  220.         // find out which patch2's will collect light
  221.         // from patch
  222.  
  223.         for (j = 0, patch2 = g_patches; j < g_num_patches; j++, patch2++)
  224.         {
  225.             vec_t           dot1;
  226.             vec_t           dot2;
  227.  
  228. #ifdef HLRAD_HULLU
  229.             vec3_t          transparency = {1.0,1.0,1.0};
  230. #endif
  231.  
  232. #ifdef HLRAD_HULLU
  233.             if (!g_CheckVisBit(i, j, transparency) || (i == j))
  234. #else
  235.             if (!g_CheckVisBit(i, j) || (i == j))
  236. #endif
  237.             {
  238.                 continue;
  239.             }
  240.  
  241.             normal2 = getPlaneFromFaceNumber(patch2->faceNumber)->normal;
  242.  
  243.             // calculate transferemnce
  244.             VectorSubtract(patch2->origin, origin, delta);
  245.  
  246.             dist = VectorNormalize(delta);
  247.             dot1 = DotProduct(delta, normal1);
  248.             dot2 = -DotProduct(delta, normal2);
  249.  
  250.             trans = (dot1 * dot2) / (dist * dist);         // Inverse square falloff factoring angle between patch normals
  251.  
  252. #ifdef HLRAD_HULLU
  253.             trans = trans * VectorAvg(transparency); //hullu: add transparency effect
  254. #endif
  255.  
  256.             if (trans >= 0)
  257.             {
  258.                 send = trans * patch2->area;
  259.  
  260.                 // Caps light from getting weird
  261.                 if (send > 0.4f)
  262.                 {
  263.                     trans = 0.4f / patch2->area;
  264.                     send = 0.4f;
  265.                 }
  266.  
  267.                 total += send;
  268.  
  269.                 // scale to 16 bit (black magic)
  270.                 trans = trans * area * INVERSE_TRANSFER_SCALE;
  271.                 if (trans >= TRANSFER_SCALE_MAX)
  272.                 {
  273.                     trans = TRANSFER_SCALE_MAX;
  274.                 }
  275.             }
  276.             else
  277.             {
  278. #if 0
  279.                 Warning("transfer < 0 (%f): dist=(%f)\n"
  280.                         "   dot1=(%f) patch@(%4.3f %4.3f %4.3f) normal(%4.3f %4.3f %4.3f)\n"
  281.                         "   dot2=(%f) patch@(%4.3f %4.3f %4.3f) normal(%4.3f %4.3f %4.3f)\n",
  282.                         trans, dist,
  283.                         dot1, patch->origin[0], patch->origin[1], patch->origin[2], patch->normal[0], patch->normal[1],
  284.                         patch->normal[2], dot2, patch2->origin[0], patch2->origin[1], patch2->origin[2],
  285.                         patch2->normal[0], patch2->normal[1], patch2->normal[2]);
  286. #endif
  287.                 trans = 0.0;
  288.             }
  289.  
  290.             *tData = trans;
  291.             *tIndex = j;
  292.             tData++;
  293.             tIndex++;
  294.             patch->iData++;
  295.             count++;
  296.         }
  297.  
  298.         // copy the transfers out
  299.         if (patch->iData)
  300.         {
  301.             unsigned        data_size = patch->iData * sizeof(transfer_data_t);
  302.  
  303.             patch->tData = (transfer_data_t*)AllocBlock(data_size);
  304.             patch->tIndex = CompressTransferIndicies(tIndex_All, patch->iData, &patch->iIndex);
  305.  
  306.             hlassume(patch->tData != NULL, assume_NoMemory);
  307.             hlassume(patch->tIndex != NULL, assume_NoMemory);
  308.  
  309.             ThreadLock();
  310.             g_transfer_data_bytes += data_size;
  311.             ThreadUnlock();
  312.  
  313.             //
  314.             // normalize all transfers so exactly 50% of the light
  315.             // is transfered to the surroundings
  316.             //
  317.  
  318.             total = 0.5 / total;
  319.             {
  320.                 unsigned        x;
  321.                 transfer_data_t* t1 = patch->tData;
  322.                 transfer_data_t* t2 = tData_All;
  323.  
  324.                 for (x = 0; x < patch->iData; x++, t1++, t2++)
  325.                 {
  326.                     (*t1) = (*t2) * total;
  327.                 }
  328.             }
  329.         }
  330.     }
  331.  
  332.     FreeBlock(tIndex_All);
  333.     FreeBlock(tData_All);
  334.  
  335.     ThreadLock();
  336.     g_total_transfer += count;
  337.     ThreadUnlock();
  338. }
  339.  
  340. #ifdef SYSTEM_WIN32
  341. #pragma warning(pop)
  342. #endif
  343.  
  344. /*
  345.  * =============
  346.  * SwapTransfersTask
  347.  * 
  348.  * Change transfers from light sent out to light collected in.
  349.  * In an ideal world, they would be exactly symetrical, but
  350.  * because the form factors are only aproximated, then normalized,
  351.  * they will actually be rather different.
  352.  * =============
  353.  */
  354. void            SwapTransfers(const int patchnum)
  355. {
  356.     patch_t*        patch = &g_patches[patchnum];
  357.     transfer_index_t* tIndex = patch->tIndex;
  358.     transfer_data_t* tData = patch->tData;
  359.     unsigned        x;
  360.  
  361.     for (x = 0; x < patch->iIndex; x++, tIndex++)
  362.     {
  363.         unsigned        size = (tIndex->size + 1);
  364.         unsigned        patchnum2 = tIndex->index;
  365.         unsigned        y;
  366.  
  367.         for (y = 0; y < size; y++, tData++, patchnum2++)
  368.         {
  369.             patch_t*        patch2 = &g_patches[patchnum2];
  370.  
  371.             if (patchnum2 > patchnum)
  372.             {                                              // done with this list
  373.                 return;
  374.             }
  375.             else if (!patch2->iData)
  376.             {                                              // Set to zero in this impossible case
  377.                 Log("patch2 has no iData\n");
  378.                 (*tData) = 0;
  379.                 continue;
  380.             }
  381.             else
  382.             {
  383.                 transfer_index_t* tIndex2 = patch2->tIndex;
  384.                 transfer_data_t* tData2 = patch2->tData;
  385.                 int             offset = FindTransferOffsetPatchnum(tIndex2, patch2, patchnum);
  386.  
  387.                 if (offset >= 0)
  388.                 {
  389.                     transfer_data_t tmp = *tData;
  390.  
  391.                     *tData = tData2[offset];
  392.                     tData2[offset] = tmp;
  393.                 }
  394.                 else
  395.                 {                                          // Set to zero in this impossible case
  396.                     Log("FindTransferOffsetPatchnum returned -1 looking for patch %d in patch %d's transfer lists\n",
  397.                         patchnum, patchnum2);
  398.                     (*tData) = 0;
  399.                     return;
  400.                 }
  401.             }
  402.         }
  403.     }
  404. }
  405.  
  406. #ifdef HLRAD_HULLU
  407. /*
  408.  * =============
  409.  * MakeScales
  410.  * 
  411.  * This is the primary time sink.
  412.  * It can be run multi threaded.
  413.  * =============
  414.  */
  415. #ifdef SYSTEM_WIN32
  416. #pragma warning(push)
  417. #pragma warning(disable: 4100)                             // unreferenced formal parameter
  418. #endif
  419. void            MakeRGBScales(const int threadnum)
  420. {
  421.     int             i;
  422.     unsigned        j;
  423.     vec3_t          delta;
  424.     vec_t           dist;
  425.     int             count;
  426.     float           trans[3];
  427.     float           trans_one;
  428.     patch_t*        patch;
  429.     patch_t*        patch2;
  430.     float           send;
  431.     vec3_t          origin;
  432.     vec_t           area;
  433.     const vec_t*    normal1;
  434.     const vec_t*    normal2;
  435.  
  436.     vec_t           total;
  437.  
  438.     transfer_raw_index_t* tIndex;
  439.     rgb_transfer_data_t* tRGBData;
  440.  
  441.     transfer_raw_index_t* tIndex_All = (transfer_raw_index_t*)AllocBlock(sizeof(transfer_index_t) * MAX_PATCHES);
  442.     rgb_transfer_data_t* tRGBData_All = (rgb_transfer_data_t*)AllocBlock(sizeof(rgb_transfer_data_t) * MAX_PATCHES);
  443.  
  444.     count = 0;
  445.  
  446.     while (1)
  447.     {
  448.         i = GetThreadWork();
  449.         if (i == -1)
  450.             break;
  451.  
  452.         patch = g_patches + i;
  453.         patch->iIndex = 0;
  454.         patch->iData = 0;
  455.  
  456.         total = 0.0;
  457.  
  458.         tIndex = tIndex_All;
  459.         tRGBData = tRGBData_All;
  460.  
  461.         VectorCopy(patch->origin, origin);
  462.         normal1 = getPlaneFromFaceNumber(patch->faceNumber)->normal;
  463.  
  464.         area = patch->area;
  465.  
  466.         // find out which patch2's will collect light
  467.         // from patch
  468.  
  469.         for (j = 0, patch2 = g_patches; j < g_num_patches; j++, patch2++)
  470.         {
  471.             vec_t           dot1;
  472.             vec_t           dot2;
  473.             vec3_t          transparency = {1.0,1.0,1.0};
  474.  
  475.             if (!g_CheckVisBit(i, j, transparency) || (i == j))
  476.             {
  477.                 continue;
  478.             }
  479.  
  480.             normal2 = getPlaneFromFaceNumber(patch2->faceNumber)->normal;
  481.  
  482.             // calculate transferemnce
  483.             VectorSubtract(patch2->origin, origin, delta);
  484.  
  485.             dist = VectorNormalize(delta);
  486.             dot1 = DotProduct(delta, normal1);
  487.             dot2 = -DotProduct(delta, normal2);
  488.  
  489.             trans_one = (dot1 * dot2) / (dist * dist);         // Inverse square falloff factoring angle between patch normals
  490.             
  491.             VectorFill(trans, trans_one);
  492.             VectorMultiply(trans, transparency, trans); //hullu: add transparency effect
  493.  
  494.             if (VectorAvg(trans) >= 0)
  495.             {
  496.                 /////////////////////////////////////////RED
  497.                 send = trans[0] * patch2->area;
  498.                 // Caps light from getting weird
  499.                 if (send > 0.4f) 
  500.                 {
  501.                     trans[0] = 0.4f / patch2->area;
  502.                     send = 0.4f;
  503.                 }
  504.                 total += send / 3.0f;
  505.                 
  506.                 /////////////////////////////////////////GREEN
  507.                 send = trans[1] * patch2->area;
  508.                 // Caps light from getting weird
  509.                 if (send > 0.4f) 
  510.                 {
  511.                     trans[1] = 0.4f / patch2->area;
  512.                     send = 0.4f;
  513.                 }
  514.                 total += send / 3.0f;
  515.  
  516.                 /////////////////////////////////////////BLUE
  517.                 send = trans[2] * patch2->area;
  518.                 // Caps light from getting weird
  519.                 if (send > 0.4f) 
  520.                 {
  521.                     trans[2] = 0.4f / patch2->area;
  522.                     send = 0.4f;
  523.                 }
  524.                 total += send / 3.0f;
  525.  
  526.                 // scale to 16 bit (black magic)
  527.                 VectorScale(trans, area * INVERSE_TRANSFER_SCALE, trans);
  528.  
  529.                 if (trans[0] >= TRANSFER_SCALE_MAX)
  530.                 {
  531.                     trans[0] = TRANSFER_SCALE_MAX;
  532.                 }
  533.                 if (trans[1] >= TRANSFER_SCALE_MAX)
  534.                 {
  535.                     trans[1] = TRANSFER_SCALE_MAX;
  536.                 }
  537.                 if (trans[2] >= TRANSFER_SCALE_MAX)
  538.                 {
  539.                     trans[2] = TRANSFER_SCALE_MAX;
  540.                 }
  541.             }
  542.             else
  543.             {
  544. #if 0
  545.                 Warning("transfer < 0 (%4.3f %4.3f %4.3f): dist=(%f)\n"
  546.                         "   dot1=(%f) patch@(%4.3f %4.3f %4.3f) normal(%4.3f %4.3f %4.3f)\n"
  547.                         "   dot2=(%f) patch@(%4.3f %4.3f %4.3f) normal(%4.3f %4.3f %4.3f)\n",
  548.                         trans[0], trans[1], trans[2], dist,
  549.                         dot1, patch->origin[0], patch->origin[1], patch->origin[2], patch->normal[0], patch->normal[1],
  550.                         patch->normal[2], dot2, patch2->origin[0], patch2->origin[1], patch2->origin[2],
  551.                         patch2->normal[0], patch2->normal[1], patch2->normal[2]);
  552. #endif
  553.                 VectorFill(trans,0.0);
  554.             }
  555.  
  556.             VectorCopy(trans, *tRGBData);
  557.             *tIndex = j;
  558.             tRGBData++;
  559.             tIndex++;
  560.             patch->iData++;
  561.             count++;
  562.         }
  563.  
  564.         // copy the transfers out
  565.         if (patch->iData)
  566.         {
  567.             unsigned data_size = patch->iData * sizeof(rgb_transfer_data_t);
  568.  
  569.             patch->tRGBData = (rgb_transfer_data_t*)AllocBlock(data_size);
  570.             patch->tIndex = CompressTransferIndicies(tIndex_All, patch->iData, &patch->iIndex);
  571.  
  572.             hlassume(patch->tRGBData != NULL, assume_NoMemory);
  573.             hlassume(patch->tIndex != NULL, assume_NoMemory);
  574.  
  575.             ThreadLock();
  576.             g_transfer_data_bytes += data_size;
  577.             ThreadUnlock();
  578.  
  579.             //
  580.             // normalize all transfers so exactly 50% of the light
  581.             // is transfered to the surroundings
  582.             //
  583.  
  584.             total = 0.5 / total;
  585.             {
  586.                 unsigned        x;
  587.                 rgb_transfer_data_t* t1 = patch->tRGBData;
  588.                 rgb_transfer_data_t* t2 = tRGBData_All;
  589.  
  590.                 for (x = 0; x < patch->iData; x++, t1++, t2++)
  591.                 {
  592.                      VectorScale( *t2, total, *t1 );
  593.                 }
  594.             }
  595.         }
  596.     }
  597.  
  598.     FreeBlock(tIndex_All);
  599.     FreeBlock(tRGBData_All);
  600.  
  601.     ThreadLock();
  602.     g_total_transfer += count;
  603.     ThreadUnlock();
  604. }
  605.  
  606. #ifdef SYSTEM_WIN32
  607. #pragma warning(pop)
  608. #endif
  609.  
  610. /*
  611.  * =============
  612.  * SwapTransfersTask
  613.  * 
  614.  * Change transfers from light sent out to light collected in.
  615.  * In an ideal world, they would be exactly symetrical, but
  616.  * because the form factors are only aproximated, then normalized,
  617.  * they will actually be rather different.
  618.  * =============
  619.  */
  620. void            SwapRGBTransfers(const int patchnum)
  621. {
  622.     patch_t*                patch    = &g_patches[patchnum];
  623.     transfer_index_t*        tIndex    = patch->tIndex;
  624.     rgb_transfer_data_t*     tRGBData= patch->tRGBData;
  625.     unsigned        x;
  626.  
  627.     for (x = 0; x < patch->iIndex; x++, tIndex++)
  628.     {
  629.         unsigned        size = (tIndex->size + 1);
  630.         unsigned        patchnum2 = tIndex->index;
  631.         unsigned        y;
  632.  
  633.         for (y = 0; y < size; y++, tRGBData++, patchnum2++)
  634.         {
  635.             patch_t*        patch2 = &g_patches[patchnum2];
  636.  
  637.             if (patchnum2 > patchnum)
  638.             {                                              // done with this list
  639.                 return;
  640.             }
  641.             else if (!patch2->iData)
  642.             {                                              // Set to zero in this impossible case
  643.                 Log("patch2 has no iData\n");
  644.                 VectorFill(*tRGBData, 0);
  645.                 continue;
  646.             }
  647.             else
  648.             {
  649.                 transfer_index_t* tIndex2 = patch2->tIndex;
  650.                 rgb_transfer_data_t* tRGBData2 = patch2->tRGBData;
  651.                 int             offset = FindTransferOffsetPatchnum(tIndex2, patch2, patchnum);
  652.  
  653.                 if (offset >= 0)
  654.                 {
  655.                     rgb_transfer_data_t tmp;
  656.                     VectorCopy(*tRGBData, tmp)
  657.  
  658.                     VectorCopy(tRGBData2[offset], *tRGBData);
  659.                     VectorCopy(tmp, tRGBData2[offset]);
  660.                 }
  661.                 else
  662.                 {                                          // Set to zero in this impossible case
  663.                     Log("FindTransferOffsetPatchnum returned -1 looking for patch %d in patch %d's transfer lists\n",
  664.                         patchnum, patchnum2);
  665.                     VectorFill(*tRGBData, 0);
  666.                     return;
  667.                 }
  668.             }
  669.         }
  670.     }
  671. }
  672.  
  673. #endif /*HLRAD_HULLU*/
  674.  
  675.  
  676. #ifndef HLRAD_HULLU
  677.  
  678. void            DumpTransfersMemoryUsage()
  679. {
  680.     Log("Transfer Lists : %u transfers\n       Indices : %u bytes\n          Data : %u bytes\n",
  681.         g_total_transfer, g_transfer_index_bytes, g_transfer_data_bytes);
  682. }
  683.  
  684. #else
  685.  
  686. //More human readable numbers
  687. void            DumpTransfersMemoryUsage()
  688. {
  689.     if(g_total_transfer > 1000*1000)
  690.         Log("Transfer Lists : %11u : %7.2fM transfers\n", g_total_transfer, g_total_transfer/(1000.0f*1000.0f));
  691.     else if(g_total_transfer > 1000)
  692.         Log("Transfer Lists : %11u : %7.2fk transfers\n", g_total_transfer, g_total_transfer/1000.0f);
  693.     else
  694.         Log("Transfer Lists : %11u transfers\n", g_total_transfer);
  695.     
  696.     if(g_transfer_index_bytes > 1024*1024)
  697.         Log("       Indices : %11u : %7.2fM bytes\n", g_transfer_index_bytes, g_transfer_index_bytes/(1024.0f * 1024.0f));
  698.     else if(g_transfer_index_bytes > 1024)
  699.         Log("       Indices : %11u : %7.2fk bytes\n", g_transfer_index_bytes, g_transfer_index_bytes/1024.0f);
  700.     else
  701.         Log("       Indices : %11u bytes\n", g_transfer_index_bytes);
  702.     
  703.     if(g_transfer_data_bytes > 1024*1024)
  704.         Log("          Data : %11u : %7.2fM bytes\n", g_transfer_data_bytes, g_transfer_data_bytes/(1024.0f * 1024.0f));
  705.     else if(g_transfer_data_bytes > 1024)
  706.         Log("          Data : %11u : %7.2fk bytes\n", g_transfer_data_bytes, g_transfer_data_bytes/1024.0f);
  707.     else
  708.         Log("       Indices : %11u bytes\n", g_transfer_data_bytes);
  709. }
  710.  
  711. #endif
  712.  
  713.